//index.js
//获取应用实例
var app = getApp();
import { Dizhi } from 'dizhi_model.js';
var dizhi = new Dizhi();
var source = '';
var inputdata = '';

var wxaSortPicker = require('../../utils/wxaSortPicker/wxaSortPicker.js');

Page({
  data: {
    showIcon: true //显示返回键以及首页

  },
  onLoad: function (e) {
    if (e.source) {
      source = e.source;
    } else {
      source = '';
    }

    inputdata = e.inputdata;
    var that = this;
    dizhi.getShengHuiRow(res => {
      //查询省列表
      wxaSortPicker.init(res, that);
    });
  },
  onShow: function () {
    var that = this;
  },
  wxaSortPickerItemTap: function (e) {
    console.log(e);
    var _city = e.target.dataset.text;
    var _typeid = e.target.dataset.value;
    var _cateId = '0';
    tt.setStorageSync('_typeid', _typeid);
    tt.setStorageSync('_cateId', _cateId);
    tt.setStorageSync('_city', _city);

    if (source == 'index') {
      var _url = '../index/index?_city=' + _city;
    } else if (source == 'ycSearch') {
      var _url = '../ycSearch/ycSearch?_city=' + _city + '&inputdata=' + inputdata + '&_typeid=' + _typeid;
    } else if(source == 'yclist'){
      var _url = '../yclist/yclist';
    } else{
      var _url = '../jqList/jqList';
    }

    console.log(_url);
    tt.reLaunch({
      url: _url //点击跳转到列表页
    });
  }
});